import java.sql.*;

public class testDB {
	public static void main(String[] args) {
        //--fork driver
		try {
            // The newInstance() call is a work around for some
            // broken Java implementations

            Class.forName("com.mysql.jdbc.Driver").newInstance();
        } catch (Exception ex) {
            // handle the error
        }
        
        //---make connection
        
        Connection conn = null;
        try {
            conn =
               DriverManager.getConnection("jdbc:mysql://10.232.129.65/test?" +
                                           "user=root&password=");
            
            
            
            System.out.println("hello");
            // Do something with the Connection
        } catch (SQLException ex) {
            // handle any errors
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
        }
        
        
      //-- assume that conn is an already created JDBC connection (see previous examples)

        Statement stmt = null;
        ResultSet rs = null;

        try {
            stmt = conn.createStatement();
            rs = stmt.executeQuery("SELECT * FROM user");
            System.out.println(rs.getString(2));

            // or alternatively, if you don't know ahead of time that
            // the query will be a SELECT...

            if (stmt.execute("desc user")) {
                rs = stmt.getResultSet();
            }

            // Now do something with the ResultSet ....
           // System.out.println(rs.getNString(5));
            
        }
        catch (SQLException ex){
            // handle any errors
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
        }
        finally {
            // it is a good idea to release
            // resources in a finally{} block
            // in reverse-order of their creation
            // if they are no-longer needed

            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException sqlEx) { } // ignore

                rs = null;
            }

            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException sqlEx) { } // ignore

                stmt = null;
            }
        }

    }

}
